package io.jt808.proto.item;


import io.norland.buffer.AutoBuffer;
import io.norland.proto.IProto;

public class PositionAdditional11OverSpeedAlarmAdditional implements IProto {
    private int positionType;
    private int areaId;

    public byte[] writeToBytes() {
        AutoBuffer buffer = new AutoBuffer();
        buffer.writeByte(positionType);
        if (positionType != 0)
            buffer.writeInt(areaId);
        return buffer.array();
    }

    public void readFromBuf(AutoBuffer buffer) {
        positionType = buffer.readByte();
        if (positionType != 0)
            areaId = buffer.readInt();
    }

    public String getPositionType() {
        switch (positionType) {
            case 0:
                return "无特定位置";
            case 1:
                return "圆形区域";
            case 2:
                return "矩形区域";
            case 3:
                return "多边形区域";
            default: //4:
                return "路段";
        }
    }
}